<%#
 Copyright 2013-2025 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<template>
  <b-navbar data-cy="navbar" toggleable="md" variant="<%_ if (clientThemeNone || !clientThemeVariantLight) { _%>dark<%_ } else { _%>light<%_ } _%>" data-bs-theme="<%_ if (clientThemeNone || !clientThemeVariantLight) { _%>dark<%_ } else { _%>light<%_ } _%>">
    <b-navbar-brand class="logo" b-link to="/">
      <span class="logo-img"></span>
      <span class="navbar-title">{{ t$('global.title') }}</span> <span class="navbar-version">{{ version }}</span>
    </b-navbar-brand>
    <b-navbar-toggle
      right
      class="jh-navbar-toggler d-lg-none"
      href="javascript:void(0);"
      data-toggle="collapse"
      target="header-tabs"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <font-awesome-icon icon="bars" />
    </b-navbar-toggle>

    <b-collapse is-nav id="header-tabs">
      <b-navbar-nav class="ms-auto">
        <b-nav-item to="/" exact>
          <span>
            <font-awesome-icon icon="fa-solid fa-home" />
            <span>{{ t$('global.menu.home') }}</span>
          </span>
        </b-nav-item>
        <b-nav-item-dropdown no-size="true" end id="entity-menu" v-if="authenticated" active-class="active" class="pointer" data-cy="entity">
          <template #button-content>
            <span class="navbar-dropdown-menu">
              <font-awesome-icon icon="th-list" />
              <span class="no-bold">{{ t$('global.menu.entities.main') }}</span>
            </span>
          </template>
          <entities-menu></entities-menu>
<%_ if (applicationTypeGateway && microfrontend) { _%>
  <%_ for (const microfrontend of microfrontends) { _%>
          <<%= microfrontend.lowercaseBaseName %>-menu></<%= microfrontend.lowercaseBaseName %>-menu>
  <%_ } _%>
<%_ } _%>
          <!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
        </b-nav-item-dropdown>
        <b-nav-item-dropdown
          right
          id="admin-menu"
          v-if="hasAnyAuthority('ROLE_ADMIN') && authenticated"
          :class="{ 'router-link-active': subIsActive('/admin') }"
          active-class="active"
          class="pointer"
          data-cy="adminMenu"
        >
          <template #button-content>
            <span class="navbar-dropdown-menu">
              <font-awesome-icon icon="users-cog" />
              <span class="no-bold">{{ t$('global.menu.admin.main') }}</span>
            </span>
          </template>
<%_ if (applicationTypeGateway && gatewayServicesApiAvailable) { _%>
          <b-dropdown-item to="/admin/gateway" active-class="active">
            <font-awesome-icon icon="road" />
            <span>{{ t$('global.menu.admin.gateway') }}</span>
          </b-dropdown-item>
<%_ } _%>
<%_ if (generateUserManagement) { _%>
          <b-dropdown-item to="/admin/user-management" active-class="active">
            <font-awesome-icon icon="users" />
            <span>{{ t$('global.menu.admin.userManagement') }}</span>
          </b-dropdown-item>
<%_ } _%>
<%_ if (communicationSpringWebsocket) { _%>
          <b-dropdown-item to="/admin/tracker" active-class="active">
            <font-awesome-icon icon="eye" />
            <span>{{ t$('global.menu.admin.tracker') }}</span>
          </b-dropdown-item>
<%_ } _%>
<%_ if (withAdminUi) { _%>
          <b-dropdown-item to="/admin/metrics" active-class="active">
            <font-awesome-icon icon="tachometer-alt" />
            <span>{{ t$('global.menu.admin.metrics') }}</span>
          </b-dropdown-item>
          <b-dropdown-item to="/admin/health" active-class="active">
            <font-awesome-icon icon="heart" />
            <span>{{ t$('global.menu.admin.health') }}</span>
          </b-dropdown-item>
          <b-dropdown-item to="/admin/configuration" active-class="active">
            <font-awesome-icon icon="cogs" />
            <span>{{ t$('global.menu.admin.configuration') }}</span>
          </b-dropdown-item>
          <b-dropdown-item to="/admin/logs" active-class="active">
            <font-awesome-icon icon="tasks" />
            <span>{{ t$('global.menu.admin.logs') }}</span>
          </b-dropdown-item>
<%_ } _%>
          <b-dropdown-item v-if="openAPIEnabled" to="/admin/docs" active-class="active">
            <font-awesome-icon icon="book" />
            <span>{{ t$('global.menu.admin.apidocs') }}</span>
          </b-dropdown-item>
<%_ if (devDatabaseTypeH2Any || databaseTypeCouchbase) { _%>
          <b-dropdown-item v-if="!inProduction" href='<% if (databaseTypeCouchbase) { %>http://localhost:8092/<% } else if (reactive) { %>http://localhost:8092/<% } else { %>./h2-console/<% } %>' target="_tab">
            <font-awesome-icon icon="database" />
            <span>{{ t$('global.menu.admin.database') }}</span>
          </b-dropdown-item>
<%_ } _%>
        </b-nav-item-dropdown>
<%_ if (enableTranslation) { _%>
        <b-nav-item-dropdown id="languagesnavBarDropdown" end v-if="languages && Object.keys(languages).length > 1">
          <template #button-content>
            <font-awesome-icon icon="flag" />
            <span class="no-bold">{{ t$('global.menu.language') }}</span>
          </template>
          <b-dropdown-item
            v-for="(value, key) in languages"
            :key="`lang-${key}`"
            @click="changeLanguage(key)"
            :class="{ active: isActiveLanguage(key) }"
          >
            {{ value.name }}
          </b-dropdown-item>
        </b-nav-item-dropdown>
<%_ } _%>
        <b-nav-item-dropdown
          right
          href="javascript:void(0);"
          id="account-menu"
          :class="{ 'router-link-active': subIsActive('/account') }"
          active-class="active"
          class="pointer"
          data-cy="accountMenu"
        >
          <template #button-content>
            <span class="navbar-dropdown-menu">
              <font-awesome-icon icon="user" />
              <span class="no-bold">{{ t$('global.menu.account.main') }}</span>
            </span>
          </template>
<%_ if (generateUserManagement) { _%>
          <b-dropdown-item data-cy="settings" to="/account/settings" v-if="authenticated" active-class="active">
            <font-awesome-icon icon="wrench" />
            <span>{{ t$('global.menu.account.settings') }}</span>
          </b-dropdown-item>
          <b-dropdown-item data-cy="passwordItem" to="/account/password" v-if="authenticated" active-class="active">
            <font-awesome-icon icon="lock" />
            <span>{{ t$('global.menu.account.password') }}</span>
          </b-dropdown-item>
<%_ } _%>
<%_ if (authenticationTypeSession && generateUserManagement) { _%>
          <b-dropdown-item to="/account/sessions" v-if="authenticated" active-class="active">
            <font-awesome-icon icon="cloud" />
            <span>{{ t$('global.menu.account.sessions') }}</span>
          </b-dropdown-item>
<%_ } _%>
          <b-dropdown-item data-cy="logout" v-if="authenticated" @click="logout()" id="logout" active-class="active">
            <font-awesome-icon icon="sign-out-alt" />
            <span>{{ t$('global.menu.account.logout') }}</span>
          </b-dropdown-item>
          <b-dropdown-item data-cy="login" v-if="!authenticated" @click="showLogin()" id="login" active-class="active">
            <font-awesome-icon icon="sign-in-alt" />
            <span>{{ t$('global.menu.account.login') }}</span>
          </b-dropdown-item>
<%_ if (generateUserManagement) { _%>
          <b-dropdown-item data-cy="register" to="/register" id="register" v-if="!authenticated" active-class="active">
            <font-awesome-icon icon="user-plus" />
            <span>{{ t$('global.menu.account.register') }}</span>
          </b-dropdown-item>
<%_ } _%>
        </b-nav-item-dropdown>
      </b-navbar-nav>
    </b-collapse>
  </b-navbar>
</template>

<script lang="ts" src="./jhi-navbar.component.ts"></script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* ==========================================================================
  Navbar
  ========================================================================== */
.navbar-version {
  font-size: 0.65em;
<%_ if (clientThemeNone) { _%>
  color: #ccc;
<%_ } _%>
}

.navbar .navbar-nav .nav-item {
  margin-right: 0.5rem;
}

@media screen and (min-width: 768px) {
  .jh-navbar-toggler {
    display: none;
  }
}

@media screen and (min-width: 768px) and (max-width: 1150px) {
  span span {
    display: none;
  }
}

.navbar-title {
  display: inline-block;
  color: white;
}

/* ==========================================================================
  Logo styles
  ========================================================================== */
.navbar-brand.logo {
  padding: 0 7px;
}

.logo .logo-img {
  height: 45px;
  display: inline-block;
  vertical-align: middle;
  width: 45px;
}

.logo-img {
  height: 100%;
  background: url('/content/images/logo-jhipster.png') no-repeat center center;
  background-size: contain;
  width: 100%;
  filter: drop-shadow(0 0 0.05rem white);
  margin: 0 5px;
}
</style>
